import request from '@/config/axios'
import { FormulaGroup, FormulaItem, columnItem } from '@/views/SysContent/types/formula'

export const RetrieveFormulaGroup = (params: { vcode: string }): Promise<IResponse> => {
  return request.get({ url: '/v1/admin/formula/group/retrieve/', params })
}
export const CreateFormulaGroup = async (data: FormulaGroup): Promise<IResponse> => {
  return request.post({ url: '/v1/admin/formula/group/create/', data })
}
export const UpdateFormulaGroup = async (data: FormulaGroup): Promise<IResponse> => {
  return request.put({ url: '/v1/admin/formula/group/update/', data })
}

export const RetrieveFormula = (params: { gid: number }): Promise<IResponse> => {
  return request.get({ url: '/v1/admin/formula/groupFormula/retrieve/', params })
}
export const CreateFormula = (data: FormulaItem): Promise<IResponse> => {
  return request.post({ url: '/v1/admin/formula/groupFormula/create/', data })
}
export const UpdateFormula = (data: FormulaItem): Promise<IResponse> => {
  return request.put({ url: '/v1/admin/formula/groupFormula/update/', data })
}

export const RetrieveColumn = (params: { fid: number }): Promise<IResponse> => {
  return request.get({ url: '/v1/admin/formula/formulaColumns/retrieve/', params })
}
export const CreateColumn = (data: columnItem): Promise<IResponse> => {
  return request.post({ url: '/v1/admin/formula/formulaColumns/create/', data })
}
export const UpdateColumn = (data: columnItem): Promise<IResponse> => {
  return request.put({ url: '/v1/admin/formula/formulaColumns/update/', data })
}
